import 'package:filelinker/mdsn.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';

class RecvTextPage extends StatefulWidget {
  const RecvTextPage({super.key, required this.text});

  final String text;

  @override
  State<RecvTextPage> createState() => _RecvTextPageState();
}

class _RecvTextPageState extends State<RecvTextPage> {
  @override
  Widget build(BuildContext context) {
    bool isDesktop = MDNS.shared.isDesktop;
    TextStyle? ts = isDesktop ? Theme.of(context).textTheme.titleSmall : null;
    return Scaffold(
      appBar: AppBar(
        leading: isDesktop ? const CloseButton() : null,
        title: Text("文本接收", style: ts),
        actions: [
          TextButton(
            onPressed: () {
              Clipboard.setData(ClipboardData(text: widget.text));
              EasyLoading.showToast("已复制到剪切板");
            },
            child: const Text("复制"),
          ),
        ],
      ),
      body: Center(
        child: Container(
          padding: const EdgeInsets.symmetric(horizontal: 20),
          child: Text(widget.text,
              style: const TextStyle(
                fontSize: 20,
              )),
        ),
      ),
    );
  }
}
